<?php
/**订单
 * Created by leiying
 * Date: 2017/11/21
 * Time: 15:01
 */

include_once(GZ_PATH . '/includes/common_func.php');
include_once(GZ_PATH . '/includes/order_func.php');
class orderAction extends Action
{
    /**订单列表
     * @author leiying
     */
    public function order_list(){
        GZ_Api::authToken();
        $uid = _POST("user_id", 0);
        $page_size   = GZ_Api::$pagination['count'];    //分页设置
        $page        = GZ_Api::$pagination['page'];     //分页设置
        $type = _POST("type", 0);

        $res = get_orders($uid,$page,$page_size,$type);
        GZ_Api::outPut($res);
    }

    /**取消订单
     * @author leiying
     */
    public function order_cancel(){
        GZ_Api::authToken();
        $uid = _POST("user_id", 0);
        $order_id = _POST("order_id", 0);

        $sql = "UPDATE ".$this->table("order").' SET `order_status`=2 WHERE `order_id`='.$order_id.' AND `user_id`='.$uid;
        $res = $this->query($sql);
        if($res){
            GZ_Api::message("取消订单成功",1);
        }else{
            GZ_Api::message("取消订单失败",2);
        }
    }

    /**查看物流
     * @author leiying
     */
    public function get_ship_info(){
        GZ_Api::authToken();
        $uid = _POST("user_id", 0);
        $shipping_id = _POST("shipping_id", 0);

        $sql = "SELECT `order_sn`,`shipping_name`,`shipping_sn` FROM ".$this->table("order_shipping").'  WHERE `id`='.$shipping_id;
        $res = $this->getRow($sql);
        $res["html_url"] = "http://test/shipping_sn".$res["shipping_sn"];
        GZ_Api::outPut($res);
    }




}
